﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace ServerNodeLib
{
	/// <summary>
	/// Represents a command for the client to execute
	/// </summary>
	[Serializable()]
	public class BatchCommand
	{
		public BatchCommand()
		{
			this.BatchCommandId = Guid.NewGuid();
			this.Arguments = String.Empty;
			this.Command = String.Empty;
			this.Path = String.Empty;

			this.ErrorOnTimeOut = false;
			this.BreakOnException = true;
			this.CaptureOutput = false;

			this.MaxTimeSeconds = (int)TimeSpan.FromHours(3).TotalSeconds;
			this.MinTimeSeconds = (int)TimeSpan.FromMinutes(3).TotalSeconds;
		}
		/// <summary>
		/// The actual command to execute. As if at the command prompt
		/// </summary>
		public String Command;
		/// <summary>
		/// Any command line arguments for the command
		/// </summary>
		public String Arguments;
		/// <summary>
		/// The client-side directory to execute the command in
		/// </summary>
		public String Path;
		/// <summary>
		/// The max amount of time this command can execute before killing it
		/// Reported as an error iff ErrorOnTimeOut is true
		/// </summary>
		public Int32 MinTimeSeconds;
		/// <summary>
		/// The min amount of time this command should execute.
		/// Reported as an error iff ErrorOnTimeOut is true
		/// </summary>
		public Int32 MaxTimeSeconds;
		/// <summary>
		/// Whether an exception should cancel the entire batch.
		/// Sometimes you can tolerate commands not being found, I guess.
		/// </summary>
		public bool BreakOnException;
		/// <summary>
		/// Whether to throw an exception if the execution time is outside
		/// the min and max windows
		/// </summary>
		public bool ErrorOnTimeOut;
		/// <summary>
		/// Whether the client should capture the program output and send it back
		/// as plain text files
		/// </summary>
		public bool CaptureOutput;
		/// <summary>
		/// A guid to uniquely identify this row in the persistent database
		/// </summary>
		public Guid BatchCommandId;
	}
}